#!/usr/bin/python

import os, sys
from datetime import datetime

taskname = "Task" + sys.argv[1]

testsdir = taskname + "/tests/"
expdir = taskname + "/expected/"
outdir = taskname + "/output/"

testfiles = os.listdir(testsdir)

cnt = 1

def checkDiff(f1, f2):
  data1 = f1.readlines()
  data2 = f2.readlines()
  if len(data1) != len(data2):
    return "WA"
  for i in range(len(data1)):
    if data1[i].strip() != data2[i].strip():
      return "WA"
  return "AC"

for testfile in testfiles:
  starttime = datetime.now()
  os.system(taskname + "/a.out" + " < " + testsdir + testfile + " > " + outdir + testfile)
  finishtime = datetime.now()
  print("Test " + str(cnt) + ". Verdict: " + checkDiff(open(expdir + testfile, "r"), open(outdir + testfile, "r")) + ". Done in " + str((finishtime - starttime).total_seconds()) + " seconds")
  cnt += 1

  
